const mongoose = require('mongoose')

const schema = new mongoose.Schema({
  buyer: { type: mongoose.SchemaTypes.ObjectId, ref: 'Buyer' }, // 买家
  orders: [{
    merchandises: { type: mongoose.SchemaTypes.ObjectId, ref: 'Merchandise' },
    size: { type: String },    // 尺码
    color: { type: String },   // 颜色
    img: { type: String },   // 颜色
    title: { type: String },   // 标题
    number: { type: Number },  // 数量
    price: { type: Number },  // 价格
    note: { type: String }, // 备注
    mailprice: { type: Number }, // 快递费
  }],
  
  allprice: { type: Number },    // 总价格
  mailprice: { type: Number }, // 快递费
  address: { 
    address: { type: String },
    name: { type: String },
    tel: { type: String },
  }, // 收货地址
  orderstate: { type: String }, // 订单状态
  mailnumber: { type: String }, // 快递单号
},{
  timestamps: true
})

module.exports = mongoose.model('Order', schema)